package com.ruoyi.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.order.domain.OrderService;
import com.ruoyi.order.service.IOrderServiceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 订单服务Controller
 * 
 * @author yun
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/orderService")
public class OrderServiceController extends BaseController
{
    @Autowired
    private IOrderServiceService orderServiceService;

    /**
     * 查询订单服务列表
     */
    @RequiresPermissions("order:orderService:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderService orderService)
    {
        startPage();
        List<OrderService> list = orderServiceService.selectOrderServiceList(orderService);
        return getDataTable(list);
    }

    /**
     * 导出订单服务列表
     */
    @RequiresPermissions("order:orderService:export")
    @Log(title = "订单服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderService orderService)
    {
        List<OrderService> list = orderServiceService.selectOrderServiceList(orderService);
        ExcelUtil<OrderService> util = new ExcelUtil<OrderService>(OrderService.class);
        util.exportExcel(response, list, "订单服务数据");
    }

    /**
     * 获取订单服务详细信息
     */
    @RequiresPermissions("order:orderService:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderServiceService.selectOrderServiceById(id));
    }

    /**
     * 新增订单服务
     */
    @RequiresPermissions("order:orderService:add")
    @Log(title = "订单服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderService orderService)
    {
        return toAjax(orderServiceService.insertOrderService(orderService));
    }

    /**
     * 修改订单服务
     */
    @RequiresPermissions("order:orderService:edit")
    @Log(title = "订单服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderService orderService)
    {
        return toAjax(orderServiceService.updateOrderService(orderService));
    }

    /**
     * 删除订单服务
     */
    @RequiresPermissions("order:orderService:remove")
    @Log(title = "订单服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderServiceService.deleteOrderServiceByIds(ids));
    }
}
